//
//  XLJudgeDayLogin.m
//  XiangLove
//
//  Created by 李传坤 on 2018/4/18.
//  Copyright © 2018年 BAOMIHUA.COM. All rights reserved.
//

#import "XLJudgeDayLogin.h"

@implementation XLJudgeDayLogin
#pragma mark -判断是否签到
+(BOOL)FindTodayLoginSinge{
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    NSString* nowDayTime = [self timeDayString];//今天的时间
    NSString *strDayTime = [userDef objectForKey:LoginSingedTimesSinged];//保存的时间串
    NSString *str1 = [userDef objectForKey:LoginSingedTodays];
    if (  str1  && [str1 integerValue] &&
        strDayTime && [nowDayTime isEqualToString:strDayTime] ) {
        return YES;
    }
    [self savDayTimesWith:@"1"];
    return NO;
}
#pragma mark -获取今天时间字符串
+(NSString *)timeDayString{
    NSDate* date               = [NSDate date];
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    return  [formatter stringFromDate:date];
}
#pragma mark -保存今天时间
+(void)savDayTimesWith:(NSString *)isShow{
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    [userDef setObject:isShow forKey:LoginSingedTodays];
    [userDef setObject:[self timeDayString] forKey:LoginSingedTimesSinged];
    [userDef synchronize];
}

@end
